#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

//升序
int asc(int a,int b) //int a = arr[i]  ,int b = arr[i+1]
{
    return (a>b);
}
//降序
int deasc(int a,int b) //int a = arr[i]  ,int b = arr[i+1]
{
    return (a<b);
}

void bubbleSort(int *arr, int len,int (*compare)(int,int)) 
{
    for(int j=0; j<len-1; j++)
    {
        for(int i=0; i<len-1-j; i++)
        {
            //if(arr[i] > arr[i+1])
            if(compare(arr[i],arr[i+1]))
            {
                int temp = arr[i];
                arr[i] = arr[i+1];
                arr[i+1] = temp;           
            }
        }
    }
}

int main()
{
    int arr[5] = {25, 3, 15, 68, 9};
    int len = sizeof(arr) / sizeof(arr[0]);
    
    bubbleSort(arr,len,deasc);

    // 输出排序后的数组
    for (int i = 0; i < len; i++) {
        printf("%d ", arr[i]);
    }
    printf("\n");

    return 0;
}